home *** CD-ROM | disk | FTP | other *** search
/ MacFormat España 27 / MacFormat n. 27 (Spain) / Mac Format 26.bin / Shareware / Programación / Word Services XCMD 1.0d3 / GoToWebPage XCMD / GoToWebPageXCMD.c < prev    next >
Encoding:
C/C++ Source or Header  |  1997-01-18  |  1.2 KB  |  66 lines

  1. // GoToWebPageXCMD.c
  2. // Copyright © Michael D. Crawford.  All Rights Reserved.
  3. // mail bug reports and enhancement suggestions to crawford@scruznet.com
  4. // get updates from:
  5. // http://www.webcom.com/wordserv/ or
  6. // http://www.wordservices.org/ once the InterNIC completes the registration
  7. // GoToWebPage url
  8. //
  9. //    Version history
  10. //    1.0d1    MDC        First release
  11.  
  12. #include <HyperXCMD.h>
  13.  
  14. #include "TestBedPrefix.h"
  15. #include "GoToWebPage.h"
  16.  
  17. void HandleStrToPStr( Handle h, StringPtr str );
  18.  
  19. #define kBatchTimeout    600
  20.  
  21. #ifdef XCMD_TESTBED
  22. void CallXCmd( XCmdPtr pBPtr )
  23. #else
  24. pascal void main( XCmdPtr pBPtr )
  25. #endif
  26. {
  27.     OSErr                err;
  28.     AEAddressDesc        spellerAddr;
  29.     Str255                strBuf;
  30.  
  31.     if ( pBPtr->paramCount != 1 ){
  32.         pBPtr->returnValue = NewHandle( 9 );
  33.         if ( pBPtr->returnValue )
  34.             BlockMoveData( "paramErr", *( pBPtr->returnValue ), 9 );
  35.     }
  36.     
  37.     HandleStrToPStr( pBPtr->params[ 0 ], strBuf );
  38.     
  39.     GoToWebPage( strBuf );
  40.  
  41.     return;
  42. }
  43.  
  44.  
  45. void HandleStrToPStr( Handle h, StringPtr str )
  46. {
  47.     short    size;
  48.     char    *p;
  49.  
  50.     // Convert a handle to a C string into a Pascal string
  51.  
  52.     p = *h;
  53.     size = 0;
  54.  
  55.     while ( *p++ )
  56.         size++;
  57.     
  58.     if ( size > 255 )
  59.         size = 255;
  60.  
  61.     str[ 0 ] = (unsigned char)size;
  62.     
  63.     BlockMove( *h, &str[ 1 ], size );
  64.  
  65.     return;
  66. }